<!--
 * @Description: 复制
 * 
 * @Author: XiongYaoYuan<xiongyaoyuan>
 * @Date: 2023-06-24 10:01:28
 * @FilePath: /yuxiuproweb/src/views/mes/pro/workorder/mods/add/copy.vue
-->
<template>
  <el-dialog
    :close-on-click-modal="false"
    v-dialogDrag
    title="复制"
    :visible.sync="shows"
    width="400px"
    append-to-body
  >
    <el-form ref="form" :model="form" :rules="rules" label-width="60px">
      <el-row>
        <el-col :span="24">
          <el-form-item label="数量:" prop="num">
            <el-input-number
              v-model="form.num"
              placeholder="请输入数量"
              controls-position="right"
              :min="1"
              :max="1000"
              style="width: 100%"
            ></el-input-number>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="shows = false">取 消</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  props: {
    show: Boolean,
    data: {
      type: Object,
    },
  },
  data() {
    return {
      form: {
        num: 1,
      },
      rules: {},
    };
  },
  computed: {
    shows: {
      get() {
        return this.show;
      },
      set(newValue) {
        this.$emit("update:show", newValue);
      },
    },
  },
  methods: {
    submitForm() {
      let cells = [];
      for (let i = 0; i < this.form.num; i++) {
        cells.push(JSON.parse(JSON.stringify(this.data)));
      }
      this.shows = false;
      this.$emit("update", cells);
    },
  },
};
</script>
